<template>
  <a-spin :spinning="confirmLoading">
    <a-form-model ref="form" :model="models" :rules="validatorRules">
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="content" required label="想要的内容">
        <a-radio-group name="content" v-model="models.content">
          <a-radio value="公众号文章的灵感">公众号文章的灵感</a-radio>
          <a-radio value="公众号文章的标题">公众号文章的标题</a-radio>
          <a-radio value="公众号文章的大纲">公众号文章的大纲</a-radio>
          <a-radio value="公众号文章的全文">公众号文章的全文</a-radio>
          <a-radio value="小红书风格种草文案">小红书风格种草文案</a-radio>
          <a-radio value="小红书风格笔记标题">小红书风格笔记标题</a-radio>
          <a-radio value="微信朋友圈文案">微信朋友圈文案</a-radio>
          <a-radio value="微博文案">微博文案</a-radio>
        </a-radio-group>
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tone" required label="选择语气">
        <a-radio-group name="tone" v-model="models.tone">
          <a-radio value="有说服力">有说服力</a-radio>
          <a-radio value="正式得体">正式得体</a-radio>
          <a-radio value="专业">专业</a-radio>
          <a-radio value="幽默">幽默</a-radio>
          <a-radio value="热情">热情</a-radio>
        </a-radio-group>
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="language" required label="语言">
        <a-radio-group name="tenantStatus" v-model="models.language">
          <a-radio value="中文">中文</a-radio>
          <a-radio value="英文">英文</a-radio>
        </a-radio-group>
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="keyword" required label="关键词">
        <a-textarea
          :rows="5"
          v-model="models.keyword"
          placeholder="请输入您想要的内容主题或者关键词。内容越详细越准确，生成的内容越好哦！"
        />
      </a-form-model-item>
      <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="wordNumber" required label="结果数字">
        <a-input-number v-model="models.wordNumber" placeholder="请输入字数(<=3000)" />
      </a-form-model-item>
    </a-form-model>
  </a-spin>
</template>

<script>
export default {
  name: 'NewMedia',
  components: {},
  props: {
    model: {
      type: Object,
      default: {},
    },
  },

  data() {
    return {
      addIconShow: true,
      shoppIngIcon: '',
      models: this.model,
      confirmLoading: false,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 12 },
      },
      validatorRules: {
        content: [{ required: true, message: '请选择想要的内容' }],
        tone: [{ required: true, message: '请选择语气' }],
        language: [{ required: true, message: '请选择语言' }],
        keyword: [
          { required: true, message: '请输入关键词' },
          { min: 1, max: 100, message: '长度在 1 到 100 个字符', trigger: 'blur' },
        ],
        wordNumber: [
          { required: true, message: '请输入结果数字' },
        ],
      },
    }
  },

  created() {},
  computed: {
    models1() {
      return this.models
    },
  },
  watch: {
    models1: {
      handler(newVal, oldVal) {
        // console.log('newVal + oldVal',newVal, oldVal)
        // console.log('handler',newVal,  this.model)
        if (!newVal.content) {
          //只需判断一个即可
          this.model.content = '公众号文章的灵感'
          this.model.tone = '有说服力'
          this.model.language = '中文'
          this.model.wordNumber = '350'
        }
      },
      deep: true,
      immediate: true,
    },
  },
  updated() {},
  mounted() {
    this.$nextTick(function () {
      console.log('11111111111111111', this.models)
    })
  },
  methods: {
    generatedBtnProp() {
      let obj = {
        content: this.models.content,
        tone: this.models.tone,
        language: this.models.language,
        keyword: this.models.keyword,
        wordNumber: this.models.wordNumber,
      }
      this.$refs.form.validate((valid) => {
        if (valid) {
          this.$emit('appApiAsk', 1, obj)
        } else {
          this.$emit('appApiAsk', 2, obj)
        }
      })
    },
  },
}
</script>

<style lang="less">
</style>